// ta.C -- beam profile on the Target and T1
// written on Jun. 1st, 2024 by SUN Yazhou
void ta(){
  TFile *f = new TFile(getenv("TMP1"), "UPDATE");
  TTree *etf = (TTree *)f->Get("etf");

  TH1 *h;
  TCanvas *c = new TCanvas("c", "DT X1-2 for post Mag dcs", 1680, 1050);
  c->Divide(2,2);
  
  c->cd(1); ((TH1 *)f->Get("UserAnaTask/trk/hTApU"))->Draw("colz");
  c->cd(2); ((TH1 *)f->Get("UserAnaTask/trk/hTApD"))->Draw("colz");
  c->cd(3); etf->Draw("pTAU[1]:pTAU[0]>>h3(500, -45., 45., 500, -45., 45.)",
    "dc0X0.GetWireId()>30", "colz");
  f->GetObject("h3", h); h->SetTitle("Target Frame");
  h->GetXaxis()->SetTitle("X [mm]"); h->GetXaxis()->SetTitle("Y [mm]");
  c->cd(4); etf->Draw("pT1[1]:pT1[0]>>h4(500, -45., 45., 500, -45., 45.)",
    "pT1[0]!=-999.&&pT1[0]!=-999.", "colz");
  f->GetObject("h4", h); h->SetTitle("Beam Spot at T1 (Tstop)");
  h->GetXaxis()->SetTitle("X [mm]"); h->GetXaxis()->SetTitle("Y [mm]");

  c->Print("ta.pdf");
} // end ta
